package com.lw.function;

import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author Administrator
 * @version 1.0
 * @description:
 * @date 2022/4/26 21:52
 */
public class TestStream2 {
    public static void main(String[] args) {
        //new Random().ints().limit(1000).forEach(System.out::println);
//        Stream.of("1","2","3","4","5","1").distinct().forEach(System.out::println);
//        System.err.println(Stream.of("1", "2", "3", "4", "5", "1").findAny().get());
//        List<Integer> collect = Stream.of("my name is qiaqia")
//                .map(s -> s.split(" "))
//                .flatMap(strings -> Arrays.stream(strings).map(s -> s.length()))
//                .collect(Collectors.toList());
//        System.err.println(collect);

//        List<Character> collect = Stream.of("my name is qiaqia")
//                .map(s -> s.split(" "))//[my name is qiaqia]
//                .flatMap(Arrays::stream)
//                .map(s -> s.chars().mapToObj(a -> (char) a))
//                .flatMap(characterStream -> characterStream.map(character -> character.charValue()))
//                .collect(Collectors.toList());
//        System.err.println(collect);

//        System.err.println(Stream.of("1", "2", "3", "4", "5", "6").reduce((s1, s2) -> s1 + s2).get());

//        System.err.println(Stream.of("7", "1", "2", "3", "4", "5", "6").sorted().collect(Collectors.toList()));

        //排序
        System.err.println(Stream.of("7", "1", "2", "3", "4", "5", "6").sorted((s1, s2) -> {
            System.err.println(s1 + "------" + s2);
            return 1;
        }).collect(Collectors.toList()));
        //所有的数据都不符合断言
        System.err.println(Stream.of("7", "1", "2", "3", "4", "5", "6").noneMatch(s -> s.length() > 1));


    }
}
